package beans;

import interfaces.IUsuarioDAO;

import javax.faces.context.FacesContext;


import persistencia.FactoriaDao;

public class cambiaPass {
    private String pass;
    private String confirmPass;

    public cambiaPass() {
        super();
    }

    public cambiaPass(String pass, String confirmPass) {
        super();
        this.pass = pass;
        this.confirmPass = confirmPass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public String getPass() {
        return pass;
    }

    public void setConfirmPass(String confirmPass) {
        this.confirmPass = confirmPass;
    }

    public String getConfirmPass() {
        return confirmPass;
    }

    public String cambiar() {
        IUsuarioDAO iu = FactoriaDao.getJDBCUsuarioDAO();
        FacesContext fc = FacesContext.getCurrentInstance();
        Usuario u =
            (Usuario)fc.getExternalContext().getSessionMap().get("usuario");

        String r;
        System.out.println(u.getDireccion());
        if (pass.equals(confirmPass)) {
            u.setPass(pass);
            iu.cambiarPass(u);
            r = "cambiado";
        } else
            r = null;

        iu.Cerrar();
        return r;
    }
}
